#import "TTTableAlertsItem.h"


///////////////////////////////////////////////////////////////////////////////////////////////////  

////////////////////////////////////////////////////////
//////   TTTableAlertsItem  /////  
////////////////////////////////////////////////////////

@implementation TTTableAlertsItem

@synthesize city = _city, helps = _helps; //, imageStyle = _imageStyle;

///////////////////////////////////////////////////////////////////////////////////////////////////
// class public

+ (id)itemWithText:(NSString*)text 
	   displayname:(NSString*)displayname
		   subject:(NSString*)subject
		 timestamp:(NSDate*)timestamp
		pictureurl:(NSString*)pictureurl 
			 city:(NSString*)city
			helps:(NSNumber*)helps
			   URL:(NSString*)url 
{
		TTTableAlertsItem* item = [[[self alloc] init] autorelease];
		item.text = text;
		item.title = subject;
		item.caption = displayname;
		item.imageURL = pictureurl;
		item.URL = url;
		item.timestamp = timestamp;
		item.city = city;
		item.helps = helps;
		return item;
	}

	
///////////////////////////////////////////////////////////////////////////////////////////////////
// NSObject

- (id)init {
	if (self = [super init]) {
		_city = @"";
		_helps = 0;
//		_imageStyle = nil;
	}
	return self;
}

- (void)dealloc {
	TT_RELEASE_SAFELY(_city);
	TT_RELEASE_SAFELY(_helps);	
//	TT_RELEASE_SAFELY(_imageStyle);
	[super dealloc];
}

///////////////////////////////////////////////////////////////////////////////////////////////////
// NSCoding

- (id)initWithCoder:(NSCoder*)decoder {
	if (self = [super initWithCoder:decoder]) {
		self.city = [decoder decodeObjectForKey:@"city"];
		self.helps = [decoder decodeObjectForKey:@"helps"];
	}
	return self;
}

- (void)encodeWithCoder:(NSCoder*)encoder {
	[super encodeWithCoder:encoder];
	if (self.city) {
		[encoder encodeObject:self.city forKey:@"city"];
	}
	if (self.helps) {
		[encoder encodeObject:self.helps forKey:@"helps"];
	}	
}

@end
